package org.leviatan.dataharbour.core.admin.impl;

import java.util.Collection;

import org.leviatan.dataharbour.core.model.PersistenceResource;
import org.leviatan.definator.client.DefinatorServiceProxy;
import org.leviatan.definator.core.model.Table;
import org.leviatan.definator.gui.RuntimeContext;


/**
 * Simply wraps the local Definator services.
 * @author Leviatan
 *
 */
public abstract class DefinatorHandler {
	
	private static DefinatorServiceProxy service;
	
	static {
		DefinatorHandler.init();
	}
	
	public static void init() {
		
		service = DefinatorServiceProxy.buildLocalProxy();
		
		service.loadConfiguration("E:/dev/shared_dev/definator-resources/conf/definator.conf");
		
		RuntimeContext.definatorService = service;
		
		service.loadRegister();
		
	}
	
	public static Table getTableModel(String tblId) {
		System.out.println(tblId);
		return service.getTableModel(Long.parseLong(tblId));
		
	}
	
	public static PersistenceResource getDataSourcesPersistenceResources(String dataSourceId) {
		
		return null;
	}
	
	public abstract void removeDefFromDataSource(String dataSourceId, String defId);
	
	public abstract void removePersistenceResourceFromDataSource(
			String dataSourceId, String persResUd);
	
	public static Collection getAllDefs() {
		return service.getTableDefinitions().values();
	}
	
	
	
}
